package com.test.json;

import java.util.ArrayList;
import java.util.List;

/**
 * JsonTreeItem. <br>
 * JsonTree 属性封装实体.
 * <p>
 * Copyright: Copyright (c) 2010-4-17 下午04:23:12
 * <p>
 * Company: 北京宽连十方数字技术有限公司
 * <p>
 * Author: liuxl@c-platform.com
 * <p>
 * Version: 1.0
 * <p>
 */
public class JsonTreeItem {

	private static String FILE_CSS = "folder";

	private static String FOLDER_CSS = "folder";

	private boolean checked = false;

	private List<JsonTreeItem> children = null;

	private boolean expanded = false;

	private Long id;

	private String text;

	/**
	 * 添加结点。 <br>
	 * 
	 * @param jsonTreeItem
	 *           结点对像
	 */
	public void addChildren(JsonTreeItem jsonTreeItem) {
		if (this.children == null) {
			this.children = new ArrayList<JsonTreeItem>();
		}
		this.children.add(jsonTreeItem);
	}

	public List<JsonTreeItem> getChildren() {
		return this.children;
	}

	public String getCls() {
		return (this.children == null) ? JsonTreeItem.FILE_CSS : JsonTreeItem.FOLDER_CSS;
	}

	public Long getId() {
		return this.id;
	}

	public String getText() {
		return this.text;
	}

	public boolean isChecked() {
		return this.checked;
	}

	public boolean isExpanded() {
		return this.expanded;
	}

	public boolean isLeaf() {
		return (this.children != null && !this.children.isEmpty()) ? false : true;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	public void setChildren(List<JsonTreeItem> children) {
		this.children = children;
	}

	public void setExpanded(boolean expanded) {
		this.expanded = expanded;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setLeaf(boolean leaf) {
	}

	public void setText(String text) {
		this.text = text;
	}

}
